﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.Serialization;
using System.Security.Permissions;

namespace Dazzle {
    [Serializable]
    public class ParameterCollection : IList, ISerializable {
        public ParameterCollection() { }

        private ArrayList _list = new ArrayList();

        [Browsable(false)]
        protected ArrayList List {
            get { return _list; }
        }

        public int Add(object value) {
            return this.List.Add(value);
        }

        public bool Contains(object value) {
            return this.List.Contains(value);
        }

        public int IndexOf(object value) {
            return this.List.IndexOf(value);
        }

        public void Insert(int index, object value) {
            this.List.Insert(index, value);
        }

        [Browsable(false)]
        public bool IsFixedSize {
            get { return this.List.IsFixedSize; }
        }

        public void Remove(object value) {
            this.List.Remove(value);
        }

        [Browsable(false)]
        object IList.this[int index] {
            get {
                return this.List[index];
            }
            set {
                this.List[index] = value;
            }
        }

        [Browsable(false)]
        public Parameter this[int index] {
            get {
                return this.List[index] as Parameter;
            }
            set { this.List[index] = value; }
        }

        public void CopyTo(Array array, int index) {
            this.List.CopyTo(array, index);
        }

        [Browsable(false)]
        public bool IsSynchronized {
            get { return this.List.IsSynchronized; }
        }

        [Browsable(false)]
        public object SyncRoot {
            get { return this.List.SyncRoot; }
        }

        public void Clear() {
            this.List.Clear();
        }

        [Browsable(false)]
        public bool IsReadOnly {
            get { return this.List.IsReadOnly; }
        }

        public void RemoveAt(int index) {
            this.List.RemoveAt(index);
        }

        [Browsable(false)]
        public int Count {
            get { return this.List.Count; }
        }

        public IEnumerator GetEnumerator() {
            return this.List.GetEnumerator();
        }

        #region ISerializable Members

        public ParameterCollection(SerializationInfo info, StreamingContext context) {
            this._list = (ArrayList)info.GetValue("List", typeof(ArrayList));
        }

        [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
        public void GetObjectData(SerializationInfo info, StreamingContext context) {
            info.AddValue("List", this.List);
        }

        #endregion
    }

}
